<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>测试fromEvent_2</title>
</head>
<body>
Weight: <input type="number" id="weight"> kg
<br/>
Height: <input type="number" id="height"> cm
<br/>
Your BMI is <div id="bmi"></div>
<script src="../node_modules/jquery/dist/jquery.js"></script>
<script src="../node_modules/rx/dist/rx.all.js"></script>
<script>
	let weight = document.getElementById('weight');
	let height = document.getElementById('height');
	let bmi = document.getElementById('bmi');
	
	let weight$ = Rx.Observable
	.fromEvent(weight, 'input')
	.pluck('target', 'value');
	
	let height$ = Rx.Observable
	.fromEvent(height, 'input')
	.pluck('target', 'value');
	
	let bmi$ = Rx.Observable
	.combineLatest(weight$, height$, (w, h) => w/(h*h/100/100));
	
	bmi$.subscribe(b => bmi.innerHTML=b);
</script>
</body>
</html>